package com.google.guava.eventbus.listeners;

import cn.hutool.log.Log;
import cn.hutool.log.LogFactory;
import com.google.common.eventbus.Subscribe;

import java.util.concurrent.TimeUnit;

/**
 * @author fuc
 * @create 2020-10-05
 */
public class SimpleListener {
  private static final Log log = LogFactory.get();

  @Subscribe
  public void doAction(final String event) {
    if (log.isInfoEnabled()) {
      log.info("Received event [{}] and will take a action", event);
    }
  }

  @Subscribe
  public void doAction2(final String event) {
    try {
      TimeUnit.MINUTES.sleep(2);
      if (log.isInfoEnabled()) {
        log.info("Received event [{}] and will take a action2", event);
      }
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
  }
}
